#include "my_ui.h"


void *speed_routine(void*arg) 
{
    while(1)
    {
    int num;
    int speed,rotation_speed,oil_temperature,oil_level;
    int KP1,KP2,KP3,KP4;
    int TP1,TP2,TP3,TP4;
    printf("please choose the item you want to change: \n");
    printf(" 1.speed   2.rotation speed  3.oil temperature  4.oil level \n");
    printf("5.turn left   6.turn right   7.zhidoerror 8.ABSerror");
    printf("9.Perror 10.zhuangxiangerror 11.ESPerror 12.hobeixiangerror\n");
    printf("13.liangceerror 14.qiangaierror 15.anquandaiPerror 16.anquanqinangerror\n");
    printf("17.shaungshanerror 18.yuanguangerror 19.jinguangerror 20.shikuoerror 21.wudengerror\n");
    printf("22.setKP1 23.setKP2 24.setKP3 25.setKP4 \n");
    printf("26.setTP1 27.setTP2 28.setTP3 29.setTP4\n");

    scanf("%d", &num);
    switch(num)
    {
        case 1:
        printf("scan speed(0-220km/h):");
        scanf("%d", &speed);
        char text[10];
        lv_snprintf(text, sizeof(text), "%d", speed);  // 这是更安全的写法
        lv_textarea_set_text(ui_textspeed, text);
        lv_label_set_text(ui_speedLabel1, text);
        lv_label_set_text(ui_speedLabel2, text);
         if(speed>=0 && speed<=220)
        speedanim_Animation(ui_speedhand, 0, speed);
        if(speed !=0 )
        timer_start();
        if(speed ==0 )
        timer_stop();
        if(speed == -1  )
        timer_reset();
        break;
        case 2:
    
        printf("scan rotation speed(0-7000r):");
        scanf("%d", &rotation_speed);
        if(rotation_speed>=0 && rotation_speed<=7000)
        zhuangsuanim_Animation(ui_zhuangsuhand, 0, rotation_speed);
        break;
        case 3:
    
        printf("scan oil temperature(40-120℃):");
        scanf("%d", &oil_temperature);
        if(oil_temperature>=100&& oil_temperature<=120)
        _ui_flag_modify(ui_shuiwenhidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
        if(oil_temperature>=40&& oil_temperature<=120)
        {
            oil_temperature=oil_temperature-40;
            temperatureanim_Animation(ui_temperaturehand, 0, oil_temperature);
        }
        break;
        case 4:
    
        printf("scan oil level(0-100%):");
        scanf("%d", &oil_level);
        if(oil_level>=0 && oil_level<=20)
            _ui_flag_modify(ui_qiyouhidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
        if(oil_level>=0 && oil_level<=100)
        youbiaoanin_Animation(ui_youbiaohand, 0, oil_level);
        break;

         case 5:  // 左转
                // 添加"左转"选项的处理逻辑
				 leftLED_Animation(ui_leftLED, 0);
        		_ui_flag_modify(ui_leftLED, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 6:  // 右转
                // 添加"右转"选项的处理逻辑
                turnRIGHT_Animation(ui_rightLED, 0);
                _ui_flag_modify(ui_rightLED, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 7:  // 制动系统故障
                // 添加"制动系统故障"选项的处理逻辑
                _ui_flag_modify(ui_zhidohidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_zhidohidden1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_zhidohidden2, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 8:  // ABS异常
                // 添加"胎压异常"选项的处理逻辑
                _ui_flag_modify(ui_ABShidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_ABShidden1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_ABShidden2, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 9:  // 拉起手刹
                // 添加"拉起手刹"选项的处理逻辑
                _ui_flag_modify(ui_Phidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_Phidden1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_Phidden2, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 10:  // 转向助力系统故障
                // 添加"转向助力系统故障"选项的处理逻辑
                _ui_flag_modify(ui_zhuangxianghidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_zhuangxianghidden1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_zhuangxianghidden2, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 11:  // ESP系统故障
                // 添加"ESP系统故障"选项的处理逻辑
                _ui_flag_modify(ui_ESPhidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_ESPhidden1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_ESPhidden2, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 12:  // 打开后备箱
                _ui_flag_modify(ui_hobeixianghidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_hobeixianghidden1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_hobeixianghidden2, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 13:  // 
                _ui_flag_modify(ui_liangcenghidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_liangcenghidden1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_liangcenghidden2, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 14:  //
            _ui_flag_modify(ui_qiangaihidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_qiangaihidden1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_qiangaihidden2, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 15:
                _ui_flag_modify(ui_anquandaihidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_anquandaihidden1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_anquandaihidden2, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 16:
                _ui_flag_modify(ui_anquanhidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_anquanhidden1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                _ui_flag_modify(ui_anquanhidden2, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 17:
                 leftLED_Animation(ui_leftLED, 0);
        		_ui_flag_modify(ui_leftLED, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                 leftLED_Animation(ui_leftLED, 0);
        		_ui_flag_modify(ui_leftLED, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 18:
                _ui_flag_modify(ui_yuanguanghidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                
                break;
            case 19:
                _ui_flag_modify(ui_jinguanghidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 20:
                _ui_flag_modify(ui_shikuodenghidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
                break;
            case 21:
                _ui_flag_modify(ui_wudenghidden, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
            case 22:
            printf("scan KP1(0-335Kpa):");
                scanf("%d", &KP1);
                char KPa[10];
                lv_snprintf(KPa, sizeof(text), "%d", KP1);
                 if(KP1>=0 && KP1<=335)
                {
                     _ui_bar_set_property(ui_BarKP1, _UI_BAR_PROPERTY_VALUE_WITH_ANIM,KP1);
                    lv_label_set_text(ui_LabelKP1, KPa);
                }
                break;
            case 23:
                printf("scan KP2(0-335Kpa):");
                scanf("%d", &KP2);
                char KPb[10];
                lv_snprintf(KPb, sizeof(text), "%d", KP2);
                if(KP2>=0 && KP2<=335)
                {
                     _ui_bar_set_property(ui_BarKP2, _UI_BAR_PROPERTY_VALUE_WITH_ANIM,KP2);
                    lv_label_set_text(ui_LabelKP2, KPb);
                }
                break;
            case 24:
                printf("scan KP3(0-335Kpa):");
                scanf("%d", &KP3);
                char KPe[10];
                lv_snprintf(KPe, sizeof(text), "%d", KP3);
                if(KP3>=0 && KP3<=335)
                {
                     _ui_bar_set_property(ui_BarKP3, _UI_BAR_PROPERTY_VALUE_WITH_ANIM,KP3);
                    lv_label_set_text(ui_LabelKP3, KPe);
                }
                break;
            case 25:
                printf("scan KP4(0-335Kpa):");
                scanf("%d", &KP4);
                char KPf[10];
                lv_snprintf(KPf, sizeof(text), "%d", KP4);
                if(KP4>=0 && KP4<=335)
                {
                     _ui_bar_set_property(ui_BarKP4, _UI_BAR_PROPERTY_VALUE_WITH_ANIM,KP4);
                    lv_label_set_text(ui_LabelKP4, KPf);
                }
                break;
            case 26:
                printf("scan KP5(0-100℃):");
                scanf("%d", &TP1);
                char TPa[10];
                lv_snprintf(TPa, sizeof(text), "%d", TP1);
                if(TP1>=0 && TP1<=100)
                {
                     _ui_bar_set_property(ui_BarTP1, _UI_BAR_PROPERTY_VALUE_WITH_ANIM,TP1);
                    lv_label_set_text(ui_LabelTP1, TPa);
                }
                break;
            case 27:
                printf("scan KP6(0-100℃):");
                scanf("%d", &TP2);
                char TPb[10];
                lv_snprintf(TPb, sizeof(text), "%d", TP2);
                if(TP2>=0 && TP2<=100)
                {
                     _ui_bar_set_property(ui_BarTP2, _UI_BAR_PROPERTY_VALUE_WITH_ANIM,TP2);
                    lv_label_set_text(ui_LabelTP2, TPb);
                }
                break;
            case 28:    
                printf("scan KP7(0-100℃):");
                scanf("%d", &TP3);
                char TPe[10];
                lv_snprintf(TPe, sizeof(text), "%d", TP3);
                if(TP3>=0 && TP3<=100)
                {
                     _ui_bar_set_property(ui_BarTP3, _UI_BAR_PROPERTY_VALUE_WITH_ANIM,TP3);
                    lv_label_set_text(ui_LabelTP3, TPe);
                }
                break;
            case 29:
                printf("scan KP8(0-100℃):");
                scanf("%d", &TP4);
                char TPf[10];
                lv_snprintf(TPf, sizeof(text), "%d", TP4);
                if(TP4>=0 && TP4<=100)
                {
                     _ui_bar_set_property(ui_BarTP4, _UI_BAR_PROPERTY_VALUE_WITH_ANIM,TP4);
                    lv_label_set_text(ui_LabelTP4, TPf);
                }
                break;
            //输入错误请重新输入
            default :
             printf("please choose the item you want to change: \n");
            break;
        
    }


    }
  
}
